package me.wsj.fengyun.dialog

import android.quickapp.windrain.databinding.DialogProtocolNewBinding
import android.view.View
import androidx.fragment.app.FragmentManager
import me.wsj.fengyun.utils.ClickUtils
import me.wsj.fengyun.utils.H5Utils
import me.wsj.fengyun.utils.TextClickUtils
import me.wsj.lib.net.HttpUtils

class PrivateDialog : BaseDialog() {


    private lateinit var viewBing: DialogProtocolNewBinding

    private var mIsClickSure = false


    companion object {


        fun shows(fm: FragmentManager): PrivateDialog {
            val dialog = PrivateDialog()
            dialog.show(fm, "PAgreeDialog")
            return dialog
        }
    }


    override fun initLayout(): View {
        viewBing = DialogProtocolNewBinding.inflate(layoutInflater)
        return viewBing.root
    }

    override fun initView() {
        TextClickUtils.addClickListener(viewBing.tvRegularDescribe, object :
            TextClickUtils.TextClickListener {
            override fun onProtocalClick() {
                H5Utils.jump(activity, H5Utils.H5_PROTECT)
            }

            override fun onPolicyClick() {
                H5Utils.jump(activity, H5Utils.H5_PRIVATE)
            }

        })
        viewBing.tvRegularPositive.setOnClickListener {
            if (!ClickUtils.isFastClick()) {
                mIsClickSure = true
                dismiss()
                onClickSure()
            }
        }
        viewBing.tvRegularNegative.setOnClickListener {
            dismissAllowingStateLoss()
        }
    }

    override fun dismiss() {
        super.dismiss()
        if (!mIsClickSure) {
            onClickCancel()
        }
    }

    override fun dismissAllowingStateLoss() {
        super.dismissAllowingStateLoss()
        if (!mIsClickSure) {
            onClickCancel()
        }
    }


}